package com.sikaryofficial.backend.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author : qinjinyuan
 * @desc : 奖项等级枚举
 * @date : 2023/11/04 10:08
 */
@Getter
@AllArgsConstructor
public enum PrizeLevelEnum {

    /**
     * 0- 特等奖
     */
    ZERO(0, "特等奖"),
    /**
     * 1- 一等奖
     */
    FIRST(1, "一等奖"),

    /**
     * 2-二等级
     */
    SECOND(2, "二等奖"),

    /**
     * 3-三等级
     */
    THIRD(3, "三等奖"),

    /**
     * 四等奖
     */
    FOURTH(4, "四等奖"),

    /**
     * 五等奖
     */
    FIFTH(5, "五等奖"),

    /**
     * 六等奖
     */
    SIXTH(6, "六等奖");

    private final Integer code;
    private final String desc;

    public static PrizeLevelEnum getByCode(Integer code) {

        return Arrays.stream(PrizeLevelEnum.values())
                .filter(pointRuleEnum -> Objects.nonNull(code) && pointRuleEnum.getCode().equals(code))
                .findFirst().orElse(null);

    }

    public static String getDescByCode(Integer code) {
        PrizeLevelEnum prizeLevelEnum = getByCode(code);
        return Objects.isNull(prizeLevelEnum) ? "" : prizeLevelEnum.getDesc();
    }

}
